//
//  LGFollowDataSymptomHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/21.
//

#import "LGFollowDataWeightHeader.h"

#define baseWidth       (Screen_W-viewPix(56))
#define dateWidth       (92/320.0)*baseWidth
#define weightWidth     (118/320.0)*baseWidth

@interface LGFollowDataWeightHeader()
/**   */
@property (nonatomic , strong)UIView *shadowView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UIView *segmentView;
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *lineView1;
/**   */
@property (nonatomic , strong)UIView *lineView2;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *weightLabel;
/**   */
@property (nonatomic , strong)UILabel *bmiLabel;

@end

@implementation LGFollowDataWeightHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self addSubview:self.shadowView];
    [self.shadowView addSubview:self.iconView];
    [self.shadowView addSubview:self.titleLabel];
    [self.shadowView addSubview:self.segmentView];
    [self.shadowView addSubview:self.baseView];
    [self.baseView addSubview:self.dateLabel];
    [self.baseView addSubview:self.weightLabel];
    [self.baseView addSubview:self.bmiLabel];
    [self.baseView addSubview:self.lineView1];
    [self.baseView addSubview:self.lineView2];
    [self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(viewPix(5));
        make.left.equalTo(self).offset(viewPix(16));
        make.right.equalTo(self).offset(-viewPix(16));
        make.bottom.equalTo(self).offset(viewPix(15));
    }];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.shadowView).offset(viewPix(12));
        make.width.height.equalTo(@(viewPix(24)));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.iconView);
    }];
    [self.segmentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.shadowView).offset(viewPix(48));
        make.left.equalTo(self.shadowView).offset(viewPix(12));
        make.right.equalTo(self.shadowView).offset(-viewPix(12));
        make.height.equalTo(@(0.5));
    }];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.segmentView.mas_bottom).offset(viewPix(12));
        make.left.right.equalTo(self.segmentView);
        make.bottom.equalTo(self.shadowView);
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.baseView);
        make.width.equalTo(@(dateWidth));
        make.height.equalTo(@(viewPix(36)));
    }];
    [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.equalTo(self.dateLabel);
        make.left.equalTo(self.dateLabel.mas_right);
        make.width.equalTo(@(weightWidth));
    }];
    [self.bmiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.equalTo(self.dateLabel);
        make.left.equalTo(self.weightLabel.mas_right);
        make.right.equalTo(self.baseView);
    }];
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.dateLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.weightLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
}

-(UIView *)shadowView{
    if(!_shadowView){
        _shadowView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:10];
        _shadowView.backgroundColor = [UIColor whiteColor];
    }
    return _shadowView;
}
-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"添加随访-体重"]];
    }
    return _iconView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"体重" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UIView *)segmentView{
    if(!_segmentView){
        _segmentView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(48), Screen_W-viewPix(56), 0.5)];
        _segmentView.backgroundColor = [UIColor colorWithString:@"#E8E8E8"];
    }
    return _segmentView;
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.layer.borderColor = [UIColor colorWithString:@"#E0E0E0"].CGColor;
        _baseView.layer.borderWidth = 1;
        _baseView.cornerRidus = 7;
    }
    return _baseView;
}

-(UIView *)lineView1{
    if(!_lineView1){
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView1;
}


-(UIView *)lineView2{
    if(!_lineView2){
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView2;
}


-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"日期" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _dateLabel;
}

-(UILabel *)weightLabel{
    if(!_weightLabel){
        _weightLabel = [UILabel lableWithText:@"体重" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _weightLabel;
}

-(UILabel *)bmiLabel{
    if(!_bmiLabel){
        _bmiLabel = [UILabel lableWithText:@"BMI" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _bmiLabel;
}

@end
